﻿/******************************************************************
******** 
 * ++ 
 * Author:    Team 1
 * Module Name  :  BasicRule.cpp
 * 
 * Description  : Source file for class BasicRule
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
 *                
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
 * 
 * Mod. History :  18.06.13 - Nguyen Khac Trung
 *                            File first created 
 *                            MP PROJECT 
 *							  The class responsibility for checking rules
 * Mod. History :  20.06.13 - Truong Cong Hau
 *                            File modified funcions CanChariotMoveTo()
 *                            MP PROJECT 
 *							  The class responsibility for checking rules
 * -- 
 
*******************************************************************
*****/

//Include files
#include "stdafx.h"
#include "BasicRule.h"

Board* BasicRule::m_pBoard = NULL;
ChessPiece* BasicRule::m_pBlackKing = NULL;
ChessPiece* BasicRule::m_pRedKing = NULL;

/**********************************************************
********
*++
* Method name : BasicRule::BasicRule ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/

BasicRule::BasicRule( )
{
}

/**********************************************************
********
*++
* Method name : BasicRule::~BasicRule ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
BasicRule::~BasicRule()
{

}

/**********************************************************
********
*++
* Method name : BasicRule::IsKingBeingChecked ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::IsKingBeingChecked(bool IsRedMove)
{
	for(int i=0; i< BoardInfo::piecesEachSide * BoardInfo::sideCount; i++)
	{
		if(IsRedMove != m_pBoard->m_plsPiece[i]->IsRedSide())
		{
			POINT piecePosition = POINT();
			piecePosition.x = m_pBoard->m_plsPiece[i]->GetRow();
			piecePosition.y = m_pBoard->m_plsPiece[i]->GetCollumn();
			if (true == IsRedMove)
			{
				POINT redKingPosition = POINT();
				redKingPosition.x = m_pRedKing->GetRow();
				redKingPosition.y = m_pRedKing->GetCollumn();			
				if(true == m_pBoard->m_plsPiece[i]->CanMoveTo(piecePosition, redKingPosition))
					return true;
			}
			else
			{
				POINT blackKingPosition = POINT();
				blackKingPosition.x = m_pBlackKing->GetRow();
				blackKingPosition.y = m_pBlackKing->GetCollumn();
				if(true == m_pBoard->m_plsPiece[i]->CanMoveTo(piecePosition, blackKingPosition))
					return true;
			}
		}
	}

	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::IsKingFaceKing ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::IsKingFaceKing()
{
	POINT blackKingPosition = POINT();
	blackKingPosition.x = m_pBlackKing->GetRow();
	blackKingPosition.y = m_pBlackKing->GetCollumn();
	POINT redKingPosition = POINT();
	redKingPosition.x = m_pRedKing->GetRow();
	redKingPosition.y = m_pRedKing->GetCollumn();
	bool isFaced = HasSameColumnAs(blackKingPosition, redKingPosition);
	if(true == isFaced)
	{
		for(int x= redKingPosition.x+1; x<blackKingPosition.x; x++)
		{
			POINT checkPosition = POINT();
			checkPosition.x = x;
			checkPosition.y = redKingPosition.y;
			if(true == m_pBoard->HasPieceAt(checkPosition))
			{
				return false;
			}
		}
		return true;
	}
	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::IsInsidePalace ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : pos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::IsInsidePalace(POINT pos)
{
	if(3<=pos.y && 5>=pos.y)
	{
		if(0<=pos.x && 2>=pos.x)
		{
			return true;
		}
		else if(7<=pos.x && 9>=pos.x)
		{
			return true;
		}
	}
	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::HasSameColumnAs ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : pos1, pos2
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::HasSameColumnAs(POINT pos1, POINT pos2)
{
	if(pos1.y == pos2.y)
	{
		return true;
	}
	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::CanElephantMoveTo ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : currPos, newPos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::CanElephantMoveTo(POINT currPos, POINT newPos)
{
	POINT topLeft = POINT();
	topLeft.x = 2;
	topLeft.y = -2;
	POINT topRight = POINT();
	topRight.x = 2;
	topRight.y = 2;
	POINT bottomLeft = POINT();
	bottomLeft.x = -2;
	bottomLeft.y = 2;
	POINT bottomRight = POINT();
	bottomRight.x = -2;
	bottomRight.y = -2;
	//
	POINT topLeftBlock = POINT();
	topLeftBlock.x = currPos.x + 1;
	topLeftBlock.y = currPos.y + -1;
	POINT topRightBlock = POINT();
	topRightBlock.x = currPos.x +  1;
	topRightBlock.y = currPos.y + 1;
	POINT bottomLeftBlock = POINT();
	bottomLeftBlock.x = currPos.x +  -1;
	bottomLeftBlock.y = currPos.y + 1;
	POINT bottomRightBlock = POINT();
	bottomRightBlock.x = currPos.x +  -1;
	bottomRightBlock.y = currPos.y + -1;
	//
	int riverBankBottom = 5;
	int riverBankTop = 4;
	//
	//Check if user want this piece to cross the river, it it is then stop piece from moving
	if(riverBankBottom<=currPos.x && riverBankTop>=newPos.x)
	{
		return false;
	}
	else if(riverBankTop>=currPos.x && riverBankBottom<=newPos.x)
	{
		return false;
	}
	//

	if((currPos.x + topLeft.x == newPos.x) && (currPos.y + topLeft.y == newPos.y) && (m_pBoard->HasPieceAt(topLeftBlock) == false))
	{
		return true;
	}
	else if((currPos.x + topRight.x == newPos.x) && (currPos.y + topRight.y == newPos.y) && (m_pBoard->HasPieceAt(topRightBlock) == false))
	{
		return true;
	}
	else if((currPos.x + bottomLeft.x == newPos.x) && (currPos.y + bottomLeft.y == newPos.y) && (m_pBoard->HasPieceAt(bottomLeftBlock) == false))
	{
		return true;
	}
	else if((currPos.x + bottomRight.x == newPos.x) && (currPos.y + bottomRight.y == newPos.y) && (m_pBoard->HasPieceAt(bottomRightBlock) == false))
	{
		return true;
	}
	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::CanChariotMoveTo ()
* Decription  : This method used to find move of Chariot Piece
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : currPos, newPos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::CanChariotMoveTo(POINT currPos, POINT newPos)
{
	if(!((newPos.x != currPos.x && newPos.y == currPos.y)||(newPos.x == currPos.x && newPos.y != currPos.y)))
	{	
		return false; // move not in straight line;
	}
	else // move in straight line;
	{
	
		// Make sure there is no piece that hinders the move from the current
		// position to the new.
		//
		//          top
		//           ^
		//           |
		//  left <-- +  ---> right
		//           |
		//           v
		//         bottom
		// 

		
		int i;

		//if the new Position is on Bottom
		if(newPos.x > currPos.x)
		{	
			//int i = newPos.x - currPos.x;
			if(1 == newPos.x - currPos.x )
				return true; // can move;
			while(newPos.x -1 > currPos.x)
			{
				currPos.x ++;
				if(true == m_pBoard->HasPieceAt(currPos))
					return false;
			};
			return true;
		}

		//if the new Position is on Top
		if(newPos.x < currPos.x)
		{	
			if(1 == currPos.x - newPos.x)
				return true;
			while(newPos.x +1 < currPos.x)
			{
				currPos.x --;
				if(true == m_pBoard->HasPieceAt(currPos))
					return false;				
			};
			return true;
		}

		//if the new Position is on RIGHT
		if(newPos.y > currPos.y)
		{	
			if(1 == newPos.y - currPos.y)
				return true;
			while(newPos.y -1 > currPos.y)
			{
				currPos.y ++;
				if(true == m_pBoard->HasPieceAt(currPos))
					return false;
				
			};
			return true;
		}

		//if the new Position is on LEFT
		if(newPos.y < currPos.y)
		{	
			if(1 == currPos.y - newPos.y)
				return true;
			while(newPos.y +1 < currPos.y)
			{
				currPos.y --;
				if(true == m_pBoard->HasPieceAt(currPos))
					return false;			
			};
			return true;
		}		
	}
}

/**********************************************************
********
*++
* Method name : BasicRule::CanAdvisorMoveTo ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : currPos, newPos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::CanAdvisorMoveTo(POINT currPos, POINT newPos)
{
	POINT topLeft = POINT();
	topLeft.x = 1;
	topLeft.y = -1;
	POINT topRight = POINT();
	topRight.x = 1;
	topRight.y = 1;
	POINT bottomLeft = POINT();
	bottomLeft.x = -1;
	bottomLeft.y = 1;
	POINT bottomRight = POINT();
	bottomRight.x = -1;
	bottomRight.y = -1;
	if(currPos.x + topLeft.x == newPos.x && currPos.y + topLeft.y == newPos.y && TRUE == IsInsidePalace(newPos))
	{
		return true;
	}
	else if(currPos.x + topRight.x == newPos.x && currPos.y + topRight.y == newPos.y && TRUE == IsInsidePalace(newPos))
	{
		return true;
	}
	else if(currPos.x + bottomLeft.x == newPos.x && currPos.y + bottomLeft.y == newPos.y && TRUE == IsInsidePalace(newPos))
	{
		return true;
	}
	else if(currPos.x + bottomRight.x == newPos.x && currPos.y + bottomRight.y == newPos.y && TRUE == IsInsidePalace(newPos))
	{
		return true;
	}
	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::CanCannonMoveTo ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : currPos, newPos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::CanCannonMoveTo(POINT currPos, POINT newPos)
{
	list<POINT> lstChessPiece;
	bool HasPieceAtNewPos = false;

	if(!((newPos.x != currPos.x && newPos.y == currPos.y)||(newPos.x == currPos.x && newPos.y != currPos.y)))
	{	
		return false;
	}
	else
	{
		if(newPos.x > currPos.x)
		{	
 			while(newPos.x - 1 > currPos.x)
			{
				currPos.x ++;
				if(true == m_pBoard->HasPieceAt(currPos))
				{
					lstChessPiece.push_back(currPos);
				}
			};
		}
		else if(newPos.x < currPos.x)
		{	
			while(newPos.x  + 1< currPos.x)
			{
				currPos.x --;
				if(true == m_pBoard->HasPieceAt(currPos))
				{
					lstChessPiece.push_back(currPos);
				}
			};
		}
		else
			if(newPos.y > currPos.y)
			{	
				while(newPos.y - 1 > currPos.y)
				{
					currPos.y ++;
					if(true == m_pBoard->HasPieceAt(currPos))
					{
						lstChessPiece.push_back(currPos);
					}
				};
			}
			else if(newPos.y < currPos.y)
			{	
				while(newPos.y + 1 < currPos.y)
				{
					currPos.y --;
					if(true == m_pBoard->HasPieceAt(currPos))
					{
						lstChessPiece.push_back(currPos);
					}
				};
			}
	}
	
	if(true == m_pBoard->HasPieceAt(newPos))
		HasPieceAtNewPos = true;
	if (0 == lstChessPiece.size() && false == HasPieceAtNewPos )  
	{
		return true;
	}
	else if (1 == lstChessPiece.size() && true == HasPieceAtNewPos) 
	{
		return true;
	}
	else
	{
		return false;
	}
}

/**********************************************************
********
*++
* Method name : BasicRule::CanGeneralMoveTo ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : currPos, newPos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::CanGeneralMoveTo(POINT currPos, POINT newPos)
{
	int index_point = 0;
	POINT value_point[4];

	// Quân phía trên
	if (currPos.x < 5)
	{
		// Có th? ti?n
		if (currPos.x < 2)
		{
			index_point++;
			value_point[index_point - 1].x = currPos.x + 1;
			value_point[index_point - 1].y = currPos.y;
		}

		// Có th? lùi
		if (currPos.x > 0)
		{
			index_point++;
			value_point[index_point - 1].x = currPos.x - 1;
			value_point[index_point - 1].y = currPos.y;
		}
	}
	// Quân phía du?i
	else
	{
		// Có th? ti?n
		if (currPos.x > 7)
		{
			index_point++;
			value_point[index_point - 1].x = currPos.x - 1;
			value_point[index_point - 1].y = currPos.y;
		}

		// Có th? lùi
		if (currPos.x < 9)
		{
			index_point++;
			value_point[index_point - 1].x = currPos.x + 1;
			value_point[index_point - 1].y = currPos.y;
		}
	}
	
	// Có th? sang trái
	if (currPos.y > 3)
	{
		index_point++;
		value_point[index_point - 1].x = currPos.x;
		value_point[index_point - 1].y = currPos.y -1;
	}

	// Có th? sang ph?i
	if (currPos.y < 5)
	{
		index_point++;
		value_point[index_point - 1].x =  currPos.x;
		value_point[index_point - 1].y = currPos.y + 1;
	}

	for (int i = 0; i < index_point; i++)
	{
		if ((newPos.x == value_point[i].x) && (newPos.y == value_point[i].y))
		{
			return true;
		}
	}

	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::CanHorseMoveTo ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : currPos, newPos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::CanHorseMoveTo(POINT currPos, POINT newPos)
{
	POINT desPos;

	//case 1
	desPos.x = currPos.x - 2;
	desPos.y = currPos.y - 1;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x - 1, currPos.y);
		}
	}
	//case 2
	desPos.x = currPos.x - 2;
	desPos.y = currPos.y + 1;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x - 1, currPos.y);
		}
	}
	//case 3
	desPos.x = currPos.x - 1;
	desPos.y = currPos.y - 2;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x, currPos.y - 1);
		}
	}
	//case 4
	desPos.x = currPos.x - 1;
	desPos.y = currPos.y + 2;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x, currPos.y + 1);
		}
	}
	//case 5
	desPos.x = currPos.x + 1;
	desPos.y = currPos.y - 2;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x, currPos.y - 1);
		}
	}
	//case 6
	desPos.x = currPos.x + 1;
	desPos.y = currPos.y + 2;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x, currPos.y + 1);
		}
	}
	//case 7
	desPos.x = currPos.x + 2;
	desPos.y = currPos.y - 1;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x + 1, currPos.y);
		}
	}
	//case 8
	desPos.x = currPos.x + 2;
	desPos.y = currPos.y + 1;

	if (desPos.x >= 0 || desPos.y >= 0)
	{
		if ((newPos.x == desPos.x) && (newPos.y == desPos.y))
		{
			return !m_pBoard->HasPieceAt(currPos.x + 1, currPos.y);
		}
	}

	return false;
}

/**********************************************************
********
*++
* Method name : BasicRule::CanSoldierMoveTo ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : currPos, newPos
* Global available : no
* Return value : bool
*               
*--
***********************************************************
********/
bool BasicRule::CanSoldierMoveTo(POINT currPos, POINT newPos, bool IsRed)
{
	int index_point = 0;	// S? di?m có th? di
	POINT value_point[3];	// Giá di?m có th? di
	
	// Quân phía trên
	if (IsRed)
	{
		// Chua sang sông
		if (currPos.x < 5){
			
			// Có th? di th?ng
			if ((1 + currPos.x) < 10)
			{
				index_point++;
				value_point[index_point - 1].x = currPos.x + 1;
				value_point[index_point - 1].y = currPos.y;
			}
		}
		// Ðã sang sông
		else {
			
			// Có th? di th?ng
			if ((1 + currPos.x) < 10)
			{
				index_point++;
				value_point[index_point - 1].x = currPos.x + 1;
				value_point[index_point - 1].y = currPos.y;
			}

			// Có th? sang trái
			if ((currPos.y - 1) > -1) {
				index_point++;
				value_point[index_point - 1].x = currPos.x;
				value_point[index_point - 1].y = currPos.y - 1;
			}
			// Có th? sang ph?i
			if ((currPos.y + 1) < 9) {
				index_point++;
				value_point[index_point - 1].x = currPos.x;
				value_point[index_point - 1].y = currPos.y + 1;
			}
		}
	}
	// Quân phía du?i
	else
	{
		// Chua sang sông
		if (currPos.x > 4){
			
			// Có th? di th?ng
			if ((currPos.x - 1) > -1)
			{
				index_point++;
				value_point[index_point - 1].x = currPos.x - 1;
				value_point[index_point - 1].y = currPos.y;
			}
		}
		// Ðã sang sông
		else {
			
			// Có th? di th?ng
			if ((currPos.x - 1) > -1)
			{
				index_point++;
				value_point[index_point - 1].x = currPos.x - 1;
				value_point[index_point - 1].y = currPos.y;
			}

			// Có th? sang trái
			if ((currPos.y - 1) > -1) {
				index_point++;
				value_point[index_point - 1].x = currPos.x;
				value_point[index_point - 1].y = currPos.y - 1;
			}

			// Có th? sang ph?i
			if ((currPos.y + 1) < 9) {
				index_point++;
				value_point[index_point - 1].x = currPos.x;
				value_point[index_point - 1].y = currPos.y + 1;
			}
		}
	}

	for (int i = 0; i < index_point; i++)
	{
		if ((newPos.x == value_point[i].x) && (newPos.y == value_point[i].y))
		{
			return true;
		}
	}

	return false;
}

void BasicRule::SetBoard(Board* _board)
{
	m_pBoard = _board;
}

void BasicRule::SetBlackKing(ChessPiece* blackKing)
{
	m_pBlackKing = blackKing;
}

void BasicRule::SetRedKing(ChessPiece* redKing)
{
	m_pRedKing = redKing;
}